package com.aree.caipiao.shsq.chain;

import com.aree.caipiao.shsq.model.ShuangSeQiuNumbers;
import com.aree.caipiao.shsq.util.LianHaoNumber;
/**
 * 连号选择器，刷选出连号的投注号码
 * @author hp-pc
 *
 */
public class LianhaoChooseChain extends ChooseChain {
	private LianHaoNumber number;
	
	public LianhaoChooseChain(LianHaoNumber lianhaoNumber) {
		this.number = lianhaoNumber;
	}

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.chain.ChooseChain#isWanted(com.aree.caipiao.shsq.model.ShuangSeQiuNumbers)
	 */
	@Override
	public boolean isWanted(ShuangSeQiuNumbers numbers) {
		int num = this.number.num();
		int[] reds = numbers.getReds();
		int[] temp = new int[num];
		for (int i = 0; i <= 6-num; i++) {
			for (int j = 0; j < num; j++) {
				temp[j] = reds[i+j];
			}
			boolean breaked = false;
			for (int k = 1; k < temp.length; k++) {
				if ((temp[k] - temp[k-1]) != 1) {
					breaked = true;
					break;
				}
			}
			if (!breaked) return true;
		}
		return false;
	}
	
	public static void main(String[] args) {
		ShuangSeQiuNumbers numbers = new ShuangSeQiuNumbers(02,05,07,25,27,31,14);
		LianhaoChooseChain chain = new LianhaoChooseChain(LianHaoNumber.TWO);
		System.out.println(chain.isWanted(numbers));
	}
}
